home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2633 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: Rezonet.net!news
  2. From: ray@ultimate-tech.com (Ray Dunn)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: swap high and low 16 bits?
  5. Date: 20 Jan 1996 02:35:26 GMT
  6. Organization: Ultimate Technographics Inc.
  7. Message-ID: <4dpkde$h3n@ns.RezoNet.NET>
  8. References: <Pine.OSF.3.91.960115174921.19742A-100000@io.UWinnipeg.ca> <ALUN.CHAMPION.96Jan16110016@g7240065.bridge.bst.bls.com> <Pine.OSF.3.91.960117143539.1414A-100000@io.UWinnipeg.ca> <821927899snz@genesis.demon.co.uk>
  9. NNTP-Posting-Host: 204.19.230.7
  10. Mime-Version: 1.0
  11. Content-Type: Text/Plain; charset=US-ASCII
  12. X-Newsreader: WinVN 0.99.7
  13.  
  14. In referenced article, Lawrence Kirby says...
  15. >In article <Pine.OSF.3.91.960117143539.1414A-100000@io.UWinnipeg.ca>
  16. >           wsimpson@uwinnipeg.ca "Bill Simpson" writes:
  17. >
  18. >>> The way I understand you is that you are using the result of time() 
  19. >>> as your random number.
  20. >>No, as the seed to the RNG.
  21. >>
  22. >>If my program runs and terminates quickly, it will get almost exactly
  23. >>the same seed on successive runs (differing only by low bits).
  24. >>
  25. >>But not if I swap high and low 16 bits.
  26. >>
  27. >>I have done this now and it works nicely.  The seeds are far apart, 
  28. >>even for runs <1 minute apart.
  29. >
  30. >Just changing high order bits may not be a good idea since with some 
  31. >RNGs this won't filter down to the lower order bits. I suggest you use 
  32. >one of the expressions I posted earlier (which are incidentally 
  33. >simpler than a full swap).
  34.  
  35. Now that I see the original poster was in fact using time to seed the 
  36. random number generator, I'm not quite sure what the problem is.  The 
  37. closesness of one seed to another seed in no way implies that the two 
  38. random sequences so produced will be "close to" each other.
  39.  
  40. A difference of only one in the value given to the seeding function 
  41. causes a totally different sequences of numbers to be produced.
  42.  
  43. -- 
  44. Ray Dunn (opinions are my own) | Phone: (514) 938 9050
  45. Montreal                       | Phax : (514) 938 5225
  46. ray@ultimate-tech.com          | Home : (514) 630 3749
  47.  
  48.